/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.ts.domain.query;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 *
 *
 * @author wwj
 * @date 2021-4-1
 */
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class TrainUserQuery {

    private static final int DEFAULT_PAGE_SIZE = 20;
    private static final int MAX_PAGE_SIZE = Integer.MAX_VALUE;

    /**
     * 返回记录的起始位置。
     */
    private Integer offset;

    /**
     * 返回记录的个数。
     */
    private Integer rows;

    /**
     * 构建一个查询。
     *
     * @param    pageIndex    页索引
     */
    public TrainUserQuery(Integer pageIndex) {
        this(pageIndex, DEFAULT_PAGE_SIZE);
    }

    /**
     * 构建一个查询。
     *
     * @param    pageIndex    页索引
     * @param    pageSize    页大小
     */
    public TrainUserQuery(Integer pageIndex, Integer pageSize) {
        int index = pageIndex == null ? 0 : pageIndex;
        int size = pageSize == null ? DEFAULT_PAGE_SIZE : pageSize;
        this.offset = index * size;
        this.rows = size;
    }

    /**
     * 构造符合条件的查询对象，仅返回一条
     *
     * @return
     */
    public static TrainUserQueryBuilder one() {
        return TrainUserQuery.builder().offset(0).rows(1);
    }

    /**
     * 构造符合条件的查询对象，控制返回的记录上限
     *
     * @return
     */
    public static TrainUserQueryBuilder max() {
        return TrainUserQuery.builder().offset(0).rows(MAX_PAGE_SIZE);
    }

    private Long userId;

    private Collection<Long> userIdS;
    private Collection<Long> trainIdS;

    private Long trainId;
    /**
     * 删除标识：0-正常，1-删除
     */
    private Boolean deleteFlag;
    /**
     * 来源于团队标识：0-否，1-是，用于去重显示
     */
    private Boolean fromGroupFlag;
    /**
     * 发行标识：0-未发行，1-发行
     */
    private Boolean releaseFlag;

    /**
     * 是否查询自学记录
     */
    private Boolean withLearnRecords;

    /**
     * 是否查询考试记录
     */
    private Boolean withExaminationRecords;

    /**
     * 是否查询实操记录
     */
    private Boolean withPracticeRecords;

    public Boolean getWithLearnRecords() {
        return Objects.equals(true, withLearnRecords);
    }

    public Boolean getWithExaminationRecords() {
        return Objects.equals(true, withExaminationRecords);
    }

    public Boolean getWithPracticeRecords() {
        return Objects.equals(true, withPracticeRecords);
    }
}
